﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class controls_usrDurationExpiry : System.Web.UI.UserControl
{
    protected int intDurationExpiry = -1;
    protected string strValidatinoGroup = "";
    protected string strErrorMessage = "Choose Duration Expiry";
    protected bool bEnabled = true;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ddlDurationExpiry.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDurationExpiry.ClientID + "','" + rfvDurationExpiry.ClientID + "');");
        }
    }

    public bool IsEnabled
    {
        get { return bEnabled; }
        set
        {
            bEnabled = value;
            SetEnabled();
        }
    }

    public void IsEnableValidation(bool bValue)
    {
        rfvDurationExpiry.Enabled = bValue;
    }

    public int DurationExpiry
    {
        get { return intDurationExpiry; }
        set { intDurationExpiry = value; }
    }

    public string ValidationGroup
    {
        get { return strValidatinoGroup; }
        set { strValidatinoGroup = value; }
    }

    public string ErrorMessage
    {
        get { return strErrorMessage; }
        set { strErrorMessage = value; }
    }

    private void SetEnabled()
    {
        ddlDurationExpiry.Enabled = bEnabled;
        rfvDurationExpiry.Enabled = bEnabled;
    }

    public int GetDurationExpiry()
    {
        intDurationExpiry = Convert.ToInt32(ddlDurationExpiry.SelectedValue);
        return intDurationExpiry;
    }

    protected override void OnPreRender(EventArgs e)
    {
        ddlDurationExpiry.SelectedValue = Convert.ToString(intDurationExpiry);
    }
}
